#ifndef _H_RM_COMMON_H_
#define _H_RM_COMMON_H_
#include <time.h>
#include <stdio.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdarg.h>
#include "lvgl/lvgl.h"

// 定义日志级别宏，可根据需要开启或关闭
#define REEMOON_LOG 1
#if REEMOON_LOG
    #define REEMOON_ERROR 1
    #define REEMOON_WARN 1
    #define REEMOON_INFO 1
    #define REEMOON_IGNORE 0
#endif

// 函数声明，使用 extern 关键字
#if REEMOON_ERROR
extern void reemoon_error_(const char *file, int line, const char *fmt,...);
#define reemoon_error(fmt, ...) reemoon_error_(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
#else
#define reemoon_error(...) ((void)0)
#endif

#if REEMOON_WARN
extern void reemoon_warn_(const char *file, int line, const char *fmt,...);
#define reemoon_warn(fmt, ...) reemoon_warn_(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
#else
#define reemoon_warn(...) ((void)0)
#endif

#if REEMOON_INFO
extern void reemoon_info_(const char *file, int line, const char *fmt, ...);
#define reemoon_info(fmt, ...) reemoon_info_(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
#else
#define reemoon_info(...) ((void)0)
#endif


#if REEMOON_IGNORE
extern void reemoon_ignore_(const char *file, int line, const char *fmt,...);
#define reemoon_ignore(fmt, ...) reemoon_ignore_(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
#else
#define reemoon_ignore(...) ((void)0)
#endif

extern bool SYSTEM_RUNNING_FALG;
extern bool SYSTEM_END_FALG;
extern bool SYSTEM_SIG_EIXT_FALG;
// 系统重启
void reemoon_system_restart(void);

// 获取系统时间
char * reemoon_get_system_time(char *time_buffer, uint8_t size);

// 删除字符串值中的字母
int reemoon_del_en(const char * src, char *dest, int src_size, int dest_size);

// 读取文件内容
int reemoon_read_file(const char *filename, char *buff, size_t size) ;

// 写文件函数
int reemoon_write_file(const char *filename, const char *buff, size_t size) ;

// 重启wifi
int reemoon_run_script(const char *script_path);
#endif